<template>
  <div class="app-container">
    <el-table border :data="tableData" style="width: 100%"
        :header-cell-style="{ textAlign: 'center' }"
        :cell-style="{ textAlign: 'center' }">
      <el-table-column type="index" width="50" label="序号"> </el-table-column>
      <el-table-column prop="applicant_order_no" label="业务订单号"/>
      <el-table-column prop="platform_desc" label="账号类型" />
      <el-table-column prop="applicant_real_name" label="申请人姓名" width="100" />
      <el-table-column prop="applicant_amount" label="提现金额" />
      <el-table-column prop="service_amount" label="手续费" />
      <el-table-column prop="service_amount_rate" label="手续费费率" />
      <el-table-column prop="arrival_amount" label="实际到账金额" width="130" />
      <el-table-column prop="bank_card_no" label="提现银行卡卡号" width="130"/>
      <el-table-column prop="status_desc" label="状态" />
      <el-table-column prop="addtime" label="添加时间"  width="130"/>
      <el-table-column prop="approvedatetime_format" label="同意/拒绝时间"  width="130"/>
      <el-table-column prop="arrivaldatetime_format" label="到账时间" width="130" />
      <el-table-column prop="remarks" label="备注" />
      <el-table-column prop="remarks" label="操作">
        <template slot-scope="scope">
          <el-button type="primary" @click="open(scope.row)" size="mini"
            >审核提现</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="listQuery.pageIndex"
      :limit.sync="listQuery.pageSize"
      @pagination="getData"
    />
  </div>
</template>

<script>
import Pagination from "@/components/Pagination";

export default {
  data() {
    return {
      listQuery: {
        pageSize: 10,
        pageIndex: 1,
      },
      total: 0,
      tableData: [],
    };
  },
  components: { Pagination },
  created() {
    this.getData();
  },
  methods: {
    async getData() {
      const res = await this.$api.finance.Withdraw(this.listQuery);
      if (res && res.code && res.code === 200) {
        this.tableData = res.data.list;
        this.total = res.data.total;
      }
    },
    tixian(type) {
      // console.log("type", type);
      // var data = {
      //   platform: 0, //平台类型(0、客户端 1、商户端)
      //   accountId: type.account_id,
      //   applywithdrawId: type.id,
      // };
      // this.getWithdrawApprovePay(data);
      // this.open();
    },
    async getWithdrawApprovePay(data) {
      const res = await this.$api.finance.WithdrawApprovePay(data);
      if (res.code === 200) {
        this.$message({
          message: "恭喜你，提现成功",
          type: "success",
        });
      }
    },
    open(type) {
      var data = {
        // platform: 0, //平台类型(0、客户端 1、商户端)
        // accountId: type.account_id,
        applywithdrawId: type.id,
      };
      this.$msgbox({
        title: "通知",
        message: "此操作不可逆，请谨慎点击",
        showCancelButton: true,
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        beforeClose: (action, instance, done) => {
          if (action === "confirm") {
            instance.confirmButtonLoading = true;
            instance.confirmButtonText = "执行中...";
            setTimeout(() => {
              done();
              this.getWithdrawApprovePay(data);
              instance.confirmButtonLoading = false;
            }, 1000);
          } else {
            done();
          }
        },
      }).then((action) => {
        // this.$message({
        //   type: "info",
        //   message: "action: " + action,
        // });
      });
    },
  },
};
</script>
